/*
 *  heap.h
 *  joosVM
 *
 *  Created by Smári Waage on 11.6.2009.
 *  Copyright 2009 smari.org. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. *
 */

#ifndef heap___ 
#define heap___ 

#include "native.h"


struct ThreadContext{
	uint32_t threadId;
	bool terminate:true;
	int status:1;
	Stack* stack;
};

class Heap{
	
public:
	
	
	static ThreadContext threads[10];
	
	static Heap* BuildHeap();
	static void TearDown();
	//	static Heap* getHeap();
	static int getHeapSize();
	
	static void* allocObject(unsigned int size);
	
	static bool shouldWedoGC();
	static void* startGC();
	static void endGC(Heap* newH, Heap* newHP);
	
	static Stack* getStack(int thread);
	static void setStack(int thread, Stack* st);

	static bool isAddressOk(void* addr);
	static bool isGCAddressOk(void* addr);
	static void printHandHP();
	static MethodArea* getMethodArea();
static void setMethodArea(MethodArea* methodArea);	

};

#endif
